﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
using System.ServiceModel.Activation;
using TryWcfService.DataSetTableAdapters;


namespace TryWcfService
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Service1" in code, svc and config file together.
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]
    [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)]
    public class DataService : IDataService
    {
        public DataClassLibrary[] GetDataByNameFromDatabase(int value)
        {
            var tempList = new List<DataClassLibrary>();
            TableTableAdapter tadp = new TableTableAdapter();
            for (int i = 0; i < tadp.GetDataById(value).Count; i++)
            {

                tempList.Add(
                    new DataClassLibrary()
               {
                   id = tadp.GetDataById(value)[i].id,
                   name = tadp.GetDataById(value)[i].name,
                   tel = tadp.GetDataById(value)[i].tel
               }
               );
            }
            return tempList.ToArray();
        }

        //public CompositeType GetDataUsingDataContract(CompositeType composite)
        //{
        //    if (composite == null)
        //    {
        //        throw new ArgumentNullException("composite");
        //    }
        //    if (composite.BoolValue)
        //    {
        //        composite.StringValue += "Suffix";
        //    }
        //    return composite;
        //}


    }
}
